<?php
class Appfront_Controllers_Plugins_Seo extends Zend_Controller_Plugin_Abstract
{
    public function routeStartup(Zend_Controller_Request_Abstract $request)
    {
    	
            $url 			= $request->getRequestUri();
            
			//Sitepath
    		$config 		= new Zend_Config_Ini(APPLICATION_PATH.'/configs/system/system.ini', APPLICATION_ENV);
    		$path 			= $config->site->path;
            
            //sitepath aus Url filtern
            $url 			= strrchr ( $url, $path );
            
            
            //Wenn die URL-Anfrage mit einem '_'  beginnt, PLugin-Prozess abbrechen
            if(substr($url, 0, 1) == '_') return;
 
            
            
            
            //Entsprechende Page-ID aus einer DB-Tabelle lesen
            
            $pModel = new Appcore_Model_Object_Page();
			
            $Page	= $pModel->getByUrlAlias($url);
            

            
            //PageID holen
            $pid			= $Page->_pid;
            
            
            //Sprache-auslesen / einfügen
            $lang 			= $Page->_langCode;
            
            //Modul-Controller-Action auslesen und setzen
            $modul 			= $Page->_ZendConfig['Modul'];
            $controller		= $Page->_ZendConfig['Controller'];
            $action			= $Page->_ZendConfig['Action'];
            
            //Werte in Registry speichern
            //Zend_Registry::set('pid', $pid);
            //Zend_Registry::set('lang', $lang);
            
            Zend_Registry::set('PageObj', $Page);
            
            
            //Anfrage nach Zend Framework Standard umschreiben
            //$request->setRequestUri("/$controller/$action/lang/$lang/pid/$pid");
            $request->setRequestUri("/$controller/$action/lang/$lang/pid/$pid");
    }
}